<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>仓库查看</title>
    <link rel="stylesheet" href="../../../../public/dist/css/layui.css" />
    <link rel="stylesheet" href="../../../../public/font/iconfont.css" />
    <link rel="stylesheet" href="../../../../css/twocss/commit.css" />
</head>

<body>
    <form class="layui-form" action="">
        <div class="select common">
            <div class="select-title">查询条件</div>

            <div class="select-con">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">仓库:</label>
                        <div class="layui-input-inline">
                            <select class="Namerawmaterials" lay-filter="TMADE">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">二级仓库:</label>
                        <div class="layui-input-inline">
                            <select class="erji" lay-filter="shas">
                                 <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="select-btn">
                    <div class="layui-bg-green comquery   Rawquery">查询</div>
                    <div class="layui-bg-green comquery   reset">重置</div>
                </div>
            </div>
        </div>
    </form>

    <div class="common-padding">
        <table lay-filter="demo">
            <thead>
                <tr>
                    <th lay-data="{type:'numbers'}">编号</th>
                    <th lay-data="{field:'username', minWidth:100, align: 'center',}">仓库</th>
                    <th lay-data="{field:'experience', minWidth:100,  align: 'center'}">二级仓库</th>
                </tr>
            </thead>
            <tbody class="Toviews">
                <!-- <tr>
                    <td>贤心1</td>
                    <td>贤心1</td>
                    <td>66</td>
                </tr> -->
            </tbody>
        </table>
    </div>
</body>


<script src="../../../../js/common/jquery.min.js"></script>
<script src="../../../../js/common/api.js"></script>
<script src="../../../../public/dist/layui.js" charset="utf-8"></script>
<script src="../../../../js/common/template-web.js"></script>
<script>
    layui.use(["table", "form", "layer"], function() {
        var $ = layui.jquery,
            layer = layui.layer,
            form = layui.form,
            listfds = {},
            table = layui.table;

        //列表
        calls();

        function calls() {
            handleAjax("OrdProcessing/getBasStorage", {}, "get").done(function(resp) {
                console.log(resp.list);
                var lisdd = null;
                $.each(resp.list, function(v, item) {
                    console.log(item);
                    $.each(item.childNodes, function(i, ited) {
                        lisdd += ' <tr><td></td><td>' + item.storagename + '</td> <td>' + ited.storagename + '</td> <td   style="display:none">' + ited.id + '</td> </tr>'
                    })
                    if (item.childNodes == null) {
                        lisdd += ' <tr><td></td><td>' + item.storagename + '</td> <td> </td> </tr>'
                    }
                })

                $(".Toviews").html(lisdd);
                table.init('demo', {
                    limit: 20
                });
            }).fail(function(err) {
                console.log(err)
            });
        }


        //仓库
        var dataresps = null;
        noAjax('OrdProcessing/getBasStorage', {}, "GET").done(function(resp) {
            dataresps = resp;
            console.log(resp)
            $.each(resp.list, function(index, item) {
                $('.Namerawmaterials').append(new Option(item.storagename, item.id));
            });
            layui.form.render("select");
            return;
        }).fail(function(err) {
            console.log(err)
        });


        //一级选出二级仓库
        form.on('select(TMADE)', function(data) {
            var elees = $(this).text();
            var dus = data.value;

            $(".erji").empty();
            $('.erji').append(new Option("---请选择---", ""));
            $.each(dataresps.list, function(index, item) {
                if (item.childNodes != null) {
                    if (item.childNodes.length > 0 && elees == item.storagename) {
                        $.each(item.childNodes, function(i, items) {
                            $('.erji').append(new Option(items.storagename, items.id));
                        })
                    }
                }
            });
            layui.form.render("select");
            return
        })

        //二级仓库
        form.on('select(shas)', function(data) {

            return
        })

        $(".Rawquery").click(function() {

        })

    });
</script>

</html>